﻿using BLL;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Model;
using Paket;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace OAElectronics.Controllers
{
    [Authorize(Policy = "开发部")]
  
    public class ExpenseRController : Controller
    {
        private readonly ExpenseRBLL _expense;
        public ExpenseRController(ExpenseRBLL expense)
        {
            _expense = expense;
        }
        public int Index([FromBody] ExpenseR e)
        {
            return _expense.Add(e);
        }
       
        public IEnumerable<ExpenseR> Expense()
        {
            return _expense.Rs();
        }
   
        public IEnumerable<ExpenseR> Expensel([FromBody] ExpenseR e)
        {
            return _expense.Rs().Where(x=>x.ExpenseType.Contains(e.ExpenseType));
        }
        [Authorize(Roles = "总经理")]
        public int update([FromBody] ExpenseR e)
        {
            return _expense.update(e.ExpenseID,e.Travel_leader);
        }
    }
}
